package controllers

//错误码 非0值代表错误 预定义了几个错误码
const (
	ErrorSuccess  = 0
	ErrorArgument = 100
	ErrorGeneric  = 101
)

//错误信息
const (
	ErrorSuccessMsg  = "成功"
	ErrorArgumentMsg = "参数错误"
)

//Response 相应结构
type Response struct {
	Code    int
	Message string
	Data    interface{}
}

//NewResponse 返回一个response
func NewResponse(code int, msg string, data interface{}) *Response {
	return &Response{Code: code, Message: msg, Data: data}
}

//NewResponseErr 返回错误Response data为nil
func NewResponseErr(code int, msg string) *Response {
	return &Response{Code: code, Message: msg}
}

//NewResponseSucc 返回成功Response
func NewResponseSucc(data interface{}) *Response {
	return &Response{Code: ErrorSuccess, Message: ErrorSuccessMsg, Data: data}
}
